import Mock from 'mockjs';
import { resultSuccess } from '../_util';

const Random = Mock.Random;

const token = Random.string('upper', 32, 32);

// import { storage } from '@/utils/Storage';
// import { ACCESS_TOKEN, CURRENT_USER, IS_SCREENLOCKED } from '@/store/mutation-types';

var permissionsList = [{}, {}, {}, {}, {}]
// // 
// const res = storage.get(CURRENT_USER, {})

//       console.log(res)

//       if (res.role == 0) {
//         console.log("管理员")
//         permissionsList = [{
//           label: '管理员',
//           value: 'admin',
//         }]
//       }else if(res.role == 1){
//         console.log("学生")
//         permissionsList = [{
//           label: '学生',
//           value: 'student',
//         }]
//       }else if(res.role == 2){
//         console.log("教师")
//         permissionsList = [{
//           label: '教师',
//           value: 'teacher',
//         }]
//       }else if(res.role == 3){
//         console.log("实验员")
//         permissionsList = [{
//           label: '实验员',
//           value: 'labAmdin',
//         }]
//       }

// permissionsList
const adminInfo = {
  userId: '1',
  username: "用户",//adminInfo
  realName: 'Admin',
  avatar: Random.image(),
  desc: 'manager',
  password: Random.string('upper', 4, 16),
  token,
  permissions:
    [
      {
        label: '系统管理员',
        value: 'admin',
      },
      {
        label: '测试',
        value: 'test',
      },
      {
        label: '学生',
        value: 'student',
      },
      {
        label: '教师',
        value: 'teacher',
      },
      {
        label: '实验员',
        value: 'labAmdin',
      },
      {
        label: '基础列表删除',
        value: 'basic_list_delete',
      },
    ],

};

export default [
  {
    url: '/api/login',
    timeout: 1000,
    method: 'post',
    response: () => {
      return resultSuccess({ token });
    },
  },
  {
    url: '/api/user/info',
    timeout: 1000,
    method: 'get',
    response: () => {
      // const token = getRequestToken(request);
      // if (!token) return resultError('Invalid token');


      //这里拿到了permission
      return resultSuccess(adminInfo);
    },
  },
];
